package com.xpffly.springboot.service.retry.impl;

import com.xpffly.springboot.service.retry.RetryService;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;

/**
 * @Author: xpeng
 * @Date: 2021/5/16 23:15
 * @Description：
 */
@Service
public class RetryServiceImpl implements RetryService {


    @Retryable(value = Exception.class, maxAttempts = 5, backoff = @Backoff(delay = 3000, multiplier = 1.5, maxDelay = 10000))
    @Override
    public void testRetry() throws Exception {
        for (int i = 0; i < 20; i++) {
            System.out.println(i);
            if (i == 10) {
                throw new Exception();
            }
            System.out.println("*************--------------");
        }
    }


}
